from w.utils.dobject.quick import DynamicInit

import w.html.settings
import w.i18n.settings
import w.blocks.settings

from w.utils.general import exception

__doc__ = """Global settings module. Enables centralized access for all settings in w package through W variable.
Follows package structure. All names are upper cased.
All default values are set for better perfomance and non-critical error 
hiding (release). So it's highly recommended to set debug values during development
and testing stage (or to use predefined function debug).

NOTICE: there are absolutely no restrictions for using settings module of any subpackage directly instead of W var.

W usage example:
@code
    from w.settings import W
    W.SUBPACKAGE_NAME...SUBPACKAGE_NAME.SETTING_NAME = new_value

Direct usage example:
@code
    import w.subpackage_name...subpackage_name.settings
    print w.subpackage_name...subpackage_name.settings.SETTING_NAME

Contents:
****************************************************************************
W:
@func debug(on) is a simple setter of debug values to all neccessary (for w authors
opinion, of course) params of all w subpackages
****************************************************************************
W.HTML:
****************************************************************************
%s
****************************************************************************
W.I18N:
****************************************************************************
%s
****************************************************************************
W.BLOCKS
****************************************************************************
%s
****************************************************************************
""" % ( w.html.settings.__doc__,
        w.i18n.settings.__doc__, 
        w.blocks.settings.__doc__)

W = DynamicInit(
        HTML=w.html.settings,
        I18N=w.i18n.settings,
        BLOCKS=w.blocks.settings,
    )

def debug(on=True):
    if on:
        W.HTML.ENABLE_STRICT_DYNAMIC_OBJECT = True
        W.HTML.ENABLE_CACHE = False
        W.HTML.ENABLE_FORMAT = True
        
        W.I18N.RESOURCE_ERROR_CALLBACK = exception
